package roles

import (
	"github.com/astaxie/beego/orm"
	"svntool/db/tables"
)

/**
 * 角色初始化类
 */
 type RoleBuilder struct{

 }

 func (r *RoleBuilder) InitRoles(){
	//初始化数据
	o, roles := orm.NewOrm(), []tables.Roles{
		{Id: 1, Name: "人员管理", Sort: 2},
		{Id: 2, Name: "创建分支", Sort: 3},
		{Id: 3, Name: "全局配置", Sort: 1},
	}
	o.InsertMulti(100, roles)
 }

 func (r *RoleBuilder) InitUserRoles(uid int){
	o := orm.NewOrm()
	user := tables.Users{Id: uid}
	//设置用户权限
	user_roleses := []tables.UserRoles{
		{Roleid: &tables.Roles{Id: 1}, Uid: &user},
		{Roleid: &tables.Roles{Id: 2}, Uid: &user},
		{Roleid: &tables.Roles{Id: 3}, Uid: &user},
	}
	o.InsertMulti(3, &user_roleses)
 }